<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Random" %>
<!doctype html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="js/libs/modernizr.min.js"></script>
    <jsp:include page="/manage/inc/header"></jsp:include>
</head>
<body>
<!--/sidebar-->
<div class="main-wrap">

    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/jscss/admin/design/">管理员管理</a><span class="crumb-step">&gt;</span><span>添加管理员</span></div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form action="<%=path%>/manage/admin/updatePass?id=${sessionScope.admin.id}" class="form" method="post">
                <table class="insert-tab" width="100%">
                    <tbody>
                    <th><i class="require-red">*</i>管理员姓名：</th>
                    <td>
                        <input class="common-text required" id="name" name="name" size="50" disabled value="${sessionScope.admin.name}" type="text"><span id="n"></span>
                    </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>管理员账户：</th>
                        <td><input class="common-text" id="account" size="50" disabled  value="${sessionScope.admin.account}" type=""><span id="q"></span></td>
                        <td><input class="common-text" id="id" size="50"  hidden value="${sessionScope.admin.id}" type=""></td>
                    </tr>
                    <th><i class="require-red">*</i>原密码:</th>
                    <td>
                        <input class="common-text required"  id="oldPass" name="aa" size="50" value="" type="password"><span id="old"></span>
                    </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>输入新密码：</th>
                        <td><input class="common-text" id="newPass" name="password" placeholder="密码包括一个大写一个小写，不少于5位数" size="50"  type="password"><span id="new"></span>
                           </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>确认新密码：</th>
                        <td><input class="common-text" id="queren" size="50"  type="password"><span id="que"></span></td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody></table>
            </form>
        </div>
    </div>
</div>
<!--/main-->
</div>
</body>
<script type="text/javascript" src="<%=path%>/Manage/static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/Manage/static/h-ui/js/H-ui.min.js"></script>
<script>
    $(function () {
        var err_old=false;
        var err_new=false;
        var err_que=false;
        $("#oldPass").blur(function () {
            var action = "<%=path%>/manage/admin/findPass";
            var passWord = $("#oldPass").val();
            var id = $("#id").val();
         $.post(action,{passWord:passWord,id:id},function (mes) {
             if(mes=="true"){
                 $("#old").html("原密码正确");
                 $("#old").css("color","green");
                 err_old=true;
             }
             if(mes=="false"){
                 $("#old").html("原密码错误");
                 $("#old").css("color","red");
                 err_old=false;
             }
         })
        })
        $("#newPass").blur(function () {
            var newpass = $("#newPass").val();
            var reg = /^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9~!@&%#_]{5,16}$/;
            var flag = reg.test(newpass);
             if(flag==true){
                 $("#new").html("√");
                 $("#new").css("color","green");
                 err_new=true;
             }
             else{
                 $("#new").html("密码格式不正确");
                 $("#new").css("color","red");
                 err_new=false
             }
        })
        $("#queren").blur(function () {
            var password=$("#newPass").val();
            var pass = $("#queren").val();
            if(password==pass){
                $("#que").html("√");
                $("#que").css("color","green");
                err_que=true;
            }
            else {
                $("#que").html("两次密码不一致");
                $("#que").css("color","red");
                err_que=false;
            }
        })
        $(".form").submit(function () {
            if(err_old=true&&err_new==true&&err_que==true){
                return true;
            }
            else {
                return false;
            }
        })
    })

</script>
</html>
